package cliente.iu;

import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JRootPane;

public class JFrameSingleton extends JFrame {

	private static final long serialVersionUID = -6948195558248816688L;

	private static JFrameSingleton instance;

	private JFrameSingleton() {		
		setSize(new Dimension(850, 650));
		setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		getRootPane().setWindowDecorationStyle(JRootPane.NONE);
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		Dimension frameSize = getSize();
		setLocation(screenSize.width / 2 - frameSize.width / 2,
				screenSize.height / 2 - frameSize.height / 2);
		setVisible(true);
		setResizable(false);
	}

	public static JFrameSingleton getSingleton() {
		if (instance == null)
			instance = new JFrameSingleton();
		return instance;
	}

	public void trocarPanel(JPanel panel) {
		getContentPane().removeAll();
		getContentPane().add(panel);
		validate();
		repaint();
		panel.validate();
	}
}
